package com.java2401.springbootv2.service.impl;

import com.java2401.springbootv2.dao.UserMapper;
import com.java2401.springbootv2.pojo.User;
import com.java2401.springbootv2.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Resource
    UserMapper userMapper;
    public User selectByPrimaryKey(Integer id) {
        return userMapper.selectByPrimaryKey(id);
    }


    @Override
    public List<User> allUserPage() {
        List<User> users = userMapper.allUserPage();
        return users;
    }

    @Override
    public String insertUser(User user) {
        int insert = userMapper.insert(user);
        return insert == 1 ? "Y" : "N";
    }

    @Override
    public Integer deleteUser(Integer id) {
        int i = userMapper.deleteByPrimaryKey(id);
        return i;
    }

    @Override
    public Integer updateUser(User user) {
        return userMapper.updateByPrimaryKey(user);
    }

    @Override
    public User selectByUserId(Integer id) {
        return userMapper.selectByPrimaryKey(id);
    }


}
